package p.ithorns.tools.validation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * NotBlankExtValidator
 *
 * 空字符校验
 *
 * @author liuhaitao
 * @version 1.0.0
 * @date 2022/5/5 14:23
 */
public class NotBlankExtValidator implements ConstraintValidator<NotBlankExt, CharSequence> {
    @Override
    public boolean isValid(CharSequence charSequence, ConstraintValidatorContext constraintValidatorContext) {
        if (charSequence == null) {
            return false;
        }

        // 去首尾空字符(包含全角空格)后判断
        return StringUtil.trimLeadTailWhitespace(charSequence.toString()).length() > 0;
    }
}
